{extend name="layout/layout" /}

{block name="pagecss"}
<link href="__STATIC__/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
<div class="row">
    <div class="col-md-12">
        <div class="portlet light">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-share font-dark"></i>
                    <span class="caption-subject font-dark bold uppercase"> 编辑扶贫项目</span>
                </div>
                <div class="actions">
                    <a class="btn btn-circle btn-icon-only btn-default fullscreen" href="javascript:;" data-original-title="" title=""> </a>
                </div>
            </div>
            <div class="portlet-body">
                <form id="ajax-form" class="form-horizontal" enctype="multipart/form-data">
                    <div class="form-body">
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        项目标题
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" maxlength="100" name="title" value="{$info.title}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        类型
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <select class="form-control" name="typeId">
                                            <option value="0">请选择</option>
                                            {volist name="typeList" id="type"}
                                            <option value="{$type.id}" {if condition="($info.typeId == $type.id)"} selected="selected" {/if}>{$type.name}</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        封面图
                                    </label>
                                    <div class="col-md-9">
                                        <div id="upload-image">
                                            <span id="upload-btn" data-multi="false">
                                                <input type="hidden" class="form-control" id="coverImg" data-required="1" name="coverImg" value="{$info.imgUrl}">
                                                <img src="{$info.imgUrl|default='__STATIC__/admin/img/default.png'}" alt="图片上传" style="width: 100px;height: 100px;" />
                                            </span>
                                        </div>
                                        <span class="help-block"> (建议尺寸：330*220) </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        贫困户<span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <button class="form-control select-povertymember" type="button" data-title="选择贫困户">{$info.povertyMember->name}</button>
                                        <input type="hidden" class="povertymemberId" name="povertymemberId" value="{$info.povertymemberId}">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        项目描述
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <textarea class="form-control" id="note" onkeyup="this.value=this.value.substring(0,800)" data-required="1" maxlength="800" rows="3" cols="20" name="content">{$info.content}</textarea><span id="text-count" value="{$info.content}">0</span>/800
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        扶贫方式<span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 istype">
                                        <div class="mt-radio-inline">
                                            <label class="mt-radio mt-radio-outline">
                                                <input type="radio" class="" name="type" value="1" {if condition="($info.type == 1)"} checked {/if}>
                                                捐物品
                                                <span></span>
                                            </label>
                                            <label class="mt-radio mt-radio-outline">
                                                <input type="radio" class="" name="type" value="2" {if condition="($info.type == 2)"} checked {/if}>
                                                捐款
                                                <span></span>
                                            </label>
                                            <label class="mt-radio mt-radio-outline">
                                                <input type="radio" class="" name="type" value="0" {if condition="($info.type == 0)"} checked {/if}>
                                                无
                                                <span></span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="type1">
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            物品名称<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" maxlength="50" name="productName" value="{$info.productName}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            物品数量<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" maxlength="4" name="productNum" value="{$info.productNum}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            收件人<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="receiveName" value="{$info.receiveName}" maxlength="10" >
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            收件地址<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="receiveAddress" value="{$info.receiveAddress}" maxlength="100" >
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            邮政编码<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="zipCode" value="{$info.zipCode}" maxlength="6" >
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="type2 hide">
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            捐款金额<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="money" value="{$info.money / 100}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            收款人<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="accountName" value="{$info.accountName}">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            账户银行<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="bankName" value="{$info.bankName}" maxlength="10" >
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-9">
                                    <div class="form-group">
                                        <label class="control-label col-md-3">
                                            银行卡号<span class="required">*</span>
                                        </label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" name="bankCode" value="{$info.bankCode}" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" maxlength="19" >
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        图片
                                    </label>
                                    <div class="col-md-9">
                                        <div id="cover-image">
                                            {volist name="imgList" id="img"}
                                            <span class="multi-image">
                                                <input type="hidden" name="imgIds" value="{$img.id}">
                                                <input type="hidden" name="imgUrl" value="{$img.imgUrl}">
                                                <img class="exist-image" src="{$img.imgUrl}" alt="">
                                                <img class="del" src="__STATIC__/pages/image/del.png" alt="">
                                            </span>
                                            {/volist}
                                            <span id="upload-cover-btn" data-multi="true" data-ajax="true" data-field="imgUrl">
                                                <img src="__STATIC__/admin/img/default.png" alt="图片上传" style="width: 100px;height: 100px;" />
                                            </span>
                                        </div>
                                        <span class="help-block"> 最多上传6张 (建议尺寸：330*220) </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        首页推荐
                                    </label>
                                    <div class="col-md-9">
                                        <input type="checkbox" class="make-switch" name="isRecommend" {if condition="($info.isRecommend == 1)"} checked {/if} data-on-color="info" data-off-color="success">
                                        <!--<input type="checkbox" class="make-switch" data-on-text="Yes" data-off-text="No" data-off-color="success">-->
                                        <span class="help-block"> 开启后将在自定义首页推荐版块显示 </span>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <input type="hidden" name="id" value="{$info.id}">

                        <hr />
                        <div class="row">
                            <div class="form-actions">
                                <div class="col-md-offset-2 col-md-10">
                                    <button type="button" id="form-submit" class="btn blue save-btn">
                                        保存 <i class="fa fa-floppy-o"></i>
                                    </button>
                                    <button type="button" class="btn default" onclick="history.go(-1);">
                                        返回 <i class="fa fa-mail-forward"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<input type="hidden" class="token_url" value="{:url('admin/Image/token')}">
<input type="hidden" class="record_url" value="{:url('admin/Image/record')}">
<input type="hidden" class="delimage_url" value="{:url('admin/Image/delete')}">

<input type="hidden" class="povertymembers_url" value="{:url('admin/iframe/povertymemberList')}">
<input type="hidden" class="aidingmembers_url" value="{:url('admin/iframe/memberList', ['selectName' => 'select-aiding', 'fieldName' => 'aidingId'])}">
{/block}

{block name="pagescript"}
<script type="text/javascript">
    var posturl = "{:url('admin/'.strtolower($model).'/editpost')}";
    var imgcount = "{$imgcount}";
    var totalImg = 6;
</script>
<script src="__STATIC__/admin/js/qiniu/plupload.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniu.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniuConfig.js" type="text/javascript"></script>
<script src="__STATIC__/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>

<script src="__STATIC__/admin/pages/js/uploadfile.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/povertyproject.js" type="text/javascript"></script>
{/block}